Kozaneba Development Diary 2021-08-03
Today's Picture of the Day
https://gyazo.com/c2db45f96be0e3dbd64f864e8dd49f58
---
https://gyazo.com/a9bf026f6d8fedf4194fad70e273b5c0
https://gyazo.com/c2db45f96be0e3dbd64f864e8dd49f58
I found that Google is telling me "This browser is not secure and will not let you log in" in a Cypress environment, this is... what should I do...
This is what happens when you can log in
https://gyazo.com/f1daec02929883a67f49b843261ec29c
https://gyazo.com/0f7adba500d9b354f594cf93fc6d71da
https://gyazo.com/b5a724ec32a5170c33982ff23d323d9e
Error
Your API key is invalid, please check you have copied it correctly.
I thought it would be easy to do, but I ran into an error with little information.
Maybe it would be better to configure Local Emulator Suite and do the authentication on a local server
2021-08-04
$ firebase init emulators
code::
=== Project Setup
First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.
? Please select an option: Use an existing project
Error: Failed to list Firebase projects. See firebase-debug.log for more info.
They say the old version of the login information fails, so you should log in again.
$ firebase logout
$ firebase login
OK, done.
$ firebase emulators:start
https://gyazo.com/c4dba360588a600e820155a5a0f04b73
https://gyazo.com/030750d60fbb7f81db39db7e3ee3566e
https://gyazo.com/581925abfc1da86af130f48d1863ba9a
It's not an anonymous login, but it's showing up as anonymous because there's no displayName.
Users can be configured on the emulator side
https://gyazo.com/66b20dfa8e4aff84601c4de6941b2c88
https://gyazo.com/14e588098aa587c00dd2e57e94cd5803
https://gyazo.com/64989f1edefacf1f3f1d8e37c17d2960
The user name is displayed properly.
---
$ firebase emulators:start
code::
⚠ firestore: Did not find a Cloud Firestore rules file specified in a firebase.json config file.
There is a syntax error in the official sample, though.
I wrote a configuration file and installed Java and it worked.
https://gyazo.com/390da980e7dfa8c5b3c2b7bd1e9e179d
Firestore is running locally, so I can always delete the whole thing without regret, and I'll try to save it in a mess.
I mean, if you can't delete everything from the test code, the test will behave differently, as it should.
There was there, there was there
The Firestore production environment does not provide a platform SDK method for flushing the database, but the Firestore emulator provides a REST endpoint for this purpose.
Cypress+Firestore+experimentalForceLongPolling=CORB
firebase.firestore().settings({ experimentalForceLongPolling: true })
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://firestore.googleapis.com/google.firestore.v1.Firestore/Write/channel?... with MIME type text/plain. See https://www.chromestatus.com/feature/5629709824032768 for more details.
you should be using the useEmulator() after the firestore.settings({ experimentalAutoDetectLongPolling: true }).
code:ts
const db = firebase.firestore();
// NG
db.useEmulator("localhost", 8080);
db.settings({ experimentalForceLongPolling: true });
// OK
db.settings({ experimentalForceLongPolling: true });
db.useEmulator("localhost", 8080);
it works!
https://gyazo.com/6a561071ab7f9abd76a19a9ba9f12d45
ExperimentalForceLongPolling must be set to true
You need to do this before you useEmulator.
---
This page is auto-translated from /nishio/Kozaneba開発日記2021-08-03. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.